package cn.jhc.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.bean.Title;
import cn.jhc.bean.User;
import cn.jhc.dao.DaoType;
import cn.jhc.dao.TitleDAO;
import cn.jhc.dao.UserDao;
import cn.jhc.factory.DAOFactory;

/**
 * Servlet implementation class ShowBookServlet
 */
@WebServlet("/showuser.do")
public class ShowUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
//		TitleDAO dao = new TitleDAO();	
		UserDao dao = (UserDao)DAOFactory.getDao(DaoType.USER);
		List<User> list = new ArrayList<User>();
		list = dao.getAll();
		req.getSession().setAttribute("list", list);
		req.getRequestDispatcher("/WEB-INF/jsp/userinfo.jsp").forward(req, resp);
	}

}
